Hi all,
I am playing with pow() function using gcc compiler. I have got some intresting error while playing. Here I am writing the code as well as the problem
main()
{
int i,j,k;
j=10;
k=2;
i=pow(j,k);
printf("i=%d",i );
}
It is the Complete code no math directory included.
when i compile this using the following command:
gcc test.c
It gives the following error
/var/tmp//ccUP0AVk.o(.tex t+0x3f): In function `main':
: undefined reference to `pow'
when i compile this using the following command:
gcc -lm test.c
It gives no error and correct output
Now I had make some changes in the program
main()
{
int i,j,k;
j=10;
k=2;
i=pow(10,2);
printf("i=%d",i );
}
when i compile this using the following command:
gcc test.c
It gives no error and correct output
Q1:-) Is it not necessary to include files in the code.
Q2:-) Why it is not giving error in the second code.
Plz help me out.
I am playing with pow() function using gcc compiler. I have got some intresting error while playing. Here I am writing the code as well as the problem
main()
{
int i,j,k;
j=10;
k=2;
i=pow(j,k);
printf("i=%d",i );
}
It is the Complete code no math directory included.
when i compile this using the following command:
gcc test.c
It gives the following error
/var/tmp//ccUP0AVk.o(.tex t+0x3f): In function `main':
: undefined reference to `pow'
when i compile this using the following command:
gcc -lm test.c
It gives no error and correct output
Now I had make some changes in the program
main()
{
int i,j,k;
j=10;
k=2;
i=pow(10,2);
printf("i=%d",i );
}
when i compile this using the following command:
gcc test.c
It gives no error and correct output
Q1:-) Is it not necessary to include files in the code.
Q2:-) Why it is not giving error in the second code.
Plz help me out.
Comment